//
//  KFDAnnouncementViewController.m
//  
//
//  Created by JIRENTIANXIANG on 6/24/15.
//
//

#import "KFDAnnouncementViewController.h"
#import "ui_config.h"
#import "KFDClient.h"
#import "NSDate+format.h"

@interface KFDAnnouncementViewController ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
//@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UIWebView *contentView;

@end

@implementation KFDAnnouncementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.uiConfigurator configureNavigationBarWithBackAction:@selector(goBack)];
    self.title=@"公告正文";
    self.view.backgroundColor=KFD_WHITE;
    KFDClient* client=[KFDClient sharedClient];
    [client getAnnouncementWithId:self.announcementId successHandler:^(KFDAnnouncement *announcement) {
        dispatch_async(dispatch_get_main_queue(), ^{
            self.titleLabel.text=announcement.title;
            self.timeLabel.text=[NSString stringWithFormat:@"%@ %@",announcement.date.year_month_day,announcement.date.hour_minute_second];
//            self.contentLabel.text=announcement.content;
            [self.contentView loadHTMLString:announcement.content baseURL:nil];
        });
    } failureHandler:^(KFDResponseBody *response) {
        
    }];
}

-(void)goBack
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
